using System;
using System.Diagnostics;
using Microsoft.CommerceServer.Catalog;
using Microsoft.CommerceServer.Inventory;
using Microsoft.CommerceServer.Tracing;
namespace Microsoft.CommerceServer.Catalog.Tools
{
	/// <summary>
	/// This class contains the public methods that are used to Get Empty Categories in a given catalog
	/// </summary>
	public class CategoryTools
	{
		#region Private Fields
		/// <summary>
		/// The site Name.
		/// </summary>
		private string siteName;
		/// <summary>
		/// Flag indicating whether inventory system should be ignored if present
		/// </summary>
		private bool ignoreInventorySystem;
		/// <summary>
		/// Stores the resource context object
		/// </summary>
		private ResourceContext context;
		#endregion
		#region Properties
		/// <summary>
		/// Get the site name.
		/// </summary>
		public string SiteName
		{
			get { return siteName; }
		}
		/// <summary>
		/// Get the flag indicating whether inventory system was ignored if present
		/// </summary>
		public bool IgnoreInventorySystem
		{
			get { return ignoreInventorySystem; }
		}
		#endregion

		#region Constructors
		/// <summary>
		/// Constructor 
		/// </summary>
		/// <param name="siteName">Name of the site</param>
		/// <param name="ignoreInventorySystem">Determine whether inventory system is integrated or not</param>
		public CategoryTools(string siteName, bool ignoreInventorySystem)
		{
			this.siteName = siteName;
			this.ignoreInventorySystem = ignoreInventorySystem;
			this.context = ResourceContext.CreateResourceContext(siteName, ignoreInventorySystem);
		}

		#endregion

		#region Public Methods
		/// <summary>
		/// Returns the list of empty categories in a given catalog.
		/// </summary>
		/// <param name="productCatalogName">Name of the product catalog</param>
		/// <returns></returns>
		public CatalogItemsDataSet GetEmptyCategories(string productCatalogName)
		{
			return context.GetEmptyCategories(productCatalogName, null);
		}

		/// <summary>
		/// Returns the list of empty categories in a given catalog.
		/// </summary>
		/// <param name="productCatalogName">Name of the product catalog</param>
		/// <param name="filterInventoryOptions">Contains options to filter Out of Stock, Backordered and Preordered items</param>
		/// <returns></returns>
		public CatalogItemsDataSet GetEmptyCategories(string productCatalogName, InventoryFilterOptions inventoryFilterOptions)
		{
			return context.GetEmptyCategories(productCatalogName, inventoryFilterOptions);
		}
		#endregion
	}
}